package org.csu.gp_store.bo;

import lombok.Data;
import org.csu.gp_store.entity.Company;
import org.csu.gp_store.entity.FacBusiness;

import java.util.ArrayList;
import java.util.List;

@Data
public class CompanyBO {
    private Long companyID;
    private String companyName;
    private String email;
    private String address;
    private int status;
    private String description;
    private long[] productIDs;
    private long[] factoryIDs;

    public static CompanyBO toCompanyBO(Company company, List<FacBusiness> facBusinessList){
        CompanyBO companyBO = new CompanyBO();
        companyBO.setCompanyID(company.getCompanyID());
        companyBO.setCompanyName(company.getCompanyName());
        companyBO.setAddress(company.getAddress());
        companyBO.setDescription(company.getDescription());
        companyBO.setEmail(company.getEmail());
        companyBO.productIDs = new long[facBusinessList.size()];
        companyBO.factoryIDs = new long[facBusinessList.size()];
        for (int i = 0; i < facBusinessList.size(); i++) {
            companyBO.productIDs[i] = facBusinessList.get(i).getProductID();
            companyBO.factoryIDs[i] = facBusinessList.get(i).getFactoryID();
        }
        return companyBO;
    }
}
